//
//  HNSH_ShopApplySelectCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/4.
//

#import "HNSH_ShopApplySelectCell.h"

@interface HNSH_ShopApplySelectCell ()

/* titleLabel */
@property (nonatomic, strong) UILabel *titleLabel;
/* desLabel */
@property (nonatomic, strong) UILabel *desLabel;
/* lineView */
@property (nonatomic, strong) UIView *lineView;

/* showIcon */
@property (nonatomic, strong) UIImageView *showIcon;
/* addressButton */
@property (nonatomic, strong) UIButton *addressButton;

@end

@implementation HNSH_ShopApplySelectCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self configView];
    }
    return self;
}

- (void)setShowAddress:(BOOL)showAddress {
    _showAddress = showAddress;
    self.addressButton.hidden = !showAddress;
}

- (void)setDesString:(NSString *)desString {
    _desString = desString;
    self.desLabel.text = desString;
}

- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}

- (void)configView {
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.desLabel];
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.showIcon];
    [self.contentView addSubview:self.addressButton];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(20);
        make.height.mas_equalTo(50).priorityHigh();
    }];
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-36);
        make.top.bottom.mas_equalTo(self.titleLabel);
        make.width.mas_equalTo(kScreenWidth-170);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    
    [self.showIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(-16);
        make.height.width.mas_equalTo(16);
    }];
    
    [self.addressButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(-26);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(21);
    }];
}

#pragma mark lazy
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = [UIColor appBlackLabelColor];
        _titleLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _titleLabel;
}

- (UILabel *)desLabel {
    if (!_desLabel) {
        _desLabel = [[UILabel alloc]init];
        _desLabel.textColor = [UIColor appGrayLabelColor];
        _desLabel.font = [UIFont systemFontOfSize:14];
        _desLabel.textAlignment = NSTextAlignmentRight;
    }
    return _desLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#EDEDED"];
    }
    return _lineView;
}

- (UIImageView *)showIcon {
    if (!_showIcon) {
        _showIcon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"base_nav_show_right"]];
    }
    return _showIcon;
}

- (UIButton *)addressButton {
    if (!_addressButton) {
        _addressButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addressButton setImage:[UIImage imageNamed:@"mine_shop_apply_address"] forState:UIControlStateNormal];
        _addressButton.hidden = YES;
        _addressButton.userInteractionEnabled = NO;
    }
    return _addressButton;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
